import request from '@/utils/request'

export function apiGetList(params, loading) {
  return request({
    url: `/ui/codeRuleController/list`,
    method: 'get',
    params,
    loading,
    autoUntie: false,
  })
}

export function apiAdd(data) {
  return request({
    url: '/ui/codeRuleController/add',
    method: 'post',
    data: data,
  })
}
export function apiEdit(data) {
  return request({
    url: '/ui/codeRuleController/edit',
    method: 'put',
    data: data,
  })
}

export function apiDel(ids) {
  return request({
    url: '/ui/codeRuleController/' + ids,
    method: 'delete',
  })
}
// 启用
export function apiEnable(data) {
  return request({
    url: '/ui/codeRuleController/enable',
    method: 'post',
    data: data,
  })
}
// 停用
export function apiDisable(data) {
  return request({
    url: '/ui/codeRuleController/disable',
    method: 'post',
    data: data,
  })
}

// 码段明细
export function apiGetToolCodeDetailList(params, loading) {
  return request({
    url: '/ui/codeRuleController/listElements',
    method: 'get',
    params,
    loading,
    resField: 'data',
  })
}
// 码段明细新增
export function apiGetToolCodeDetailAdd(data, loading) {
  return request({
    url: '/ui/codeRuleElementController/add',
    method: 'post',
    data: data,
    loading,
  })
}
// 码段明细修改
export function apiToolCodeDetaiEdit(data, loading) {
  return request({
    url: '/ui/codeRuleElementController/edit',
    method: 'put',
    data: data,
    loading,
  })
}
// 码段明细删除
export function apiToolCodeDetaiDel(ids) {
  return request({
    url: '/ui/codeRuleElementController/' + ids,
    method: 'delete',
  })
}
// 上下移
export function apiToolCodeDetaiMove(data, type = 'up') {
  let url = ''
  if (type === 'up') {
    url = '/ui/codeRuleElementController/moveUp'
  } else {
    url = '/ui/codeRuleElementController/moveDown'
  }
  return request({
    url,
    method: 'post',
    data,
  })
}

// 针对枚举的新增或修改
export function apiAddOrEditEnum(data, loading) {
  return request({
    url: '/ui/autoCodeEnumController/batchAddOrEdit',
    method: 'post',
    data: data,
    loading,
  })
}

// 枚举列表查询
export function apiGetReceiptCodeRulesDetailEnumList(data) {
  return request({
    url: '/ui/autoCodeEnumController/list',
    method: 'get',
    params: data,
    resField: 'data',
  })
}

// 枚举列表查询
export function apiGetReceiptCodeRulesDetailEnumDel(id) {
  return request({
    url: '/ui/autoCodeEnumController/' + id,
    method: 'delete',
  })
}
